package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }

    @Override
    public List<User> findUserByNameAndAddress(String username, String password) {
        // String condition = "username = {0} and password = {1}";//错误
        String condition = "username = '%s' and password = '%s'";//正确
        condition = String.format(condition, username, password);
        return userDao.findUserByNameAndAddress(condition);
    }
}
